package io.renren.modules.generator.service.impl;

import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.generator.dao.IndustryDao;
import io.renren.modules.generator.entity.IndustryEntity;
import io.renren.modules.generator.service.IndustryService;


@Service("industryService")
public class IndustryServiceImpl extends ServiceImpl<IndustryDao, IndustryEntity> implements IndustryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<IndustryEntity> wrapper = new QueryWrapper<>();
        if (MapUtils.isNotEmpty(params) && params.get("key") != null) {
            wrapper.like("industry_name", params.get("key"));
        }
        IPage<IndustryEntity> page = this.page(
                new Query<IndustryEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

    @Override
    public List<IndustryEntity> queryAll() {
        return this.baseMapper.selectList(new QueryWrapper<>());
    }

}